using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;

using EntLibEC.Cmn;
using EntLibEC.Info.Basic;
using EntLibEC.Biz;
using EntLibEC.Biz.Basic;

namespace EntLibEC.View.Basic
{
	/// <summary>
	/// Summary description for PayTypeSearch.
	/// </summary>
	public partial class PayTypeSearch : PageBase
	{
	
		protected void Page_Load(object sender, System.EventArgs e)
		{
			btnAdd.Attributes["onclick"]= "javascript:openWindowS2('PayTypeOpt.aspx?opt=add'); return false;";
			if (!Page.IsPostBack)
				BindGrid();
		}
		private void BindGrid()
		{
			DataTable dt = BuildPayTypeTable();
			DataGrid1.DataSource = dt;
			DataGrid1.DataBind();
			
			int rows = 0;
			if ( Util.HasMoreRow(dt) )
				rows = dt.Rows.Count;
			Assert(lblMessage, rows.ToString() + " record(s)", 1);
		}
		private DataTable BuildPayTypeTable()
		{
			DataTable table = new DataTable("PayType");
			table.Columns.Add(new DataColumn("SysNo",typeof(int)));
			table.Columns.Add(new DataColumn("PayTypeID",typeof(string)));
			table.Columns.Add(new DataColumn("PayTypeName",typeof(string)));
			table.Columns.Add(new DataColumn("PayTypeDesc",typeof(string)));
			table.Columns.Add(new DataColumn("Period",typeof(string)));
			table.Columns.Add(new DataColumn("PayRate",typeof(string)));
			table.Columns.Add(new DataColumn("IsNet", typeof(string)));
			table.Columns.Add(new DataColumn("IsPayWhenRecv",typeof(string)));
			table.Columns.Add(new DataColumn("IsOnlineShow",typeof(string)));
			

			SortedList sl = ASPManager.GetInstance().GetPayTypeList(false);
			if ( sl == null )
				return table;

			foreach(PayTypeInfo item in sl.Values)
			{
				DataRow row = table.NewRow();
				row["SysNo"] = item.SysNo;
				row["PayTypeID"] = item.PayTypeID;
				row["PayTypeName"] = "<a href=\"javascript:openWindowS2('PayTypeOpt.aspx?sysno=" + item.SysNo.ToString() + "&opt=update')" + "\">" + item.PayTypeName + "</a>";
				row["PayTypeDesc"] = item.PayTypeDesc;
				row["Period"] = item.Period;
				row["PayRate"] = item.PayRate.ToString(AppConst.DecimalFormat);
				row["IsNet"] = AppEnum.GetYNStatus(item.IsNet);
				row["IsPayWhenRecv"] = AppEnum.GetYNStatus(item.IsPayWhenRecv);
				row["IsOnlineShow"] = AppEnum.GetYNStatus(item.IsOnlineShow);

				table.Rows.Add(row);
			}
			return table;

		}

		protected void btnSearch_Click(object sender, System.EventArgs e)
		{
			BindGrid();
		}
	}
}
